#include "MeshResetNameDialog.h"
#include "ui_MeshResetNameDialog.h"
//#include "MeshGeoSubWidget.h"

#include "GUIFrame/MainWindow.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "OperatorsInterface/ParaWidgetInterfaceOperator.h"
#include "FITK_Interface/FITKInterfaceMesh/FITKUnstructuredMeshVTK.h"
//#include "FITK_Component/FITKWidget/FITKTabWidget.h"

#include <QVBoxLayout>
#include <QSpacerItem>

namespace GUI
{
    MeshResetNameDialog::MeshResetNameDialog(EventOper::ParaWidgetInterfaceOperator * oper, Interface::FITKUnstructuredMeshVTK* obj,int &index) :
        GUIDialogBase(dynamic_cast<MainWindow*>(FITKAPP->getGlobalData()->getMainWindow())),
        _oper(oper), _obj(obj), _index(index)
    {
        _ui = new Ui::MeshResetNameDialog();
        _ui->setupUi(this);
        init();
    }

    MeshResetNameDialog::~MeshResetNameDialog()
    {
        if (_ui) {
            delete _ui;
            _ui = nullptr;
        }
    }

    void MeshResetNameDialog::init()
    {
        QString startname = _obj->getDataObjectName();
        _ui->label_Name->setText(startname);
    }

    void MeshResetNameDialog::on_pushButton_Cancel_clicked()
    {
        if (_oper == nullptr)return;
        _oper->execProfession();

        this->reject();
    }

    void MeshResetNameDialog::on_pushButton_OK_clicked()
    {
        if (_obj == nullptr)return;
        if (_oper == nullptr)return;

        //如果清除的是当前页面数据对象，清除界面
        QString newname = _ui->label_Name->text();
        _obj->setDataObjectName(newname);

        _oper->execProfession();
        emit sigResetNameFinish();

        this->accept();
    }


}

